from config.all_paths import config_variable_path
from config.global_variable import JZ
from utils.file_handling.txt_handling import extract_txt


def JZDataProcessing(data, res):
    """
    减重工作台数据处理
    """
    # 获取减重工作台数据
    if data.get('case_name') == '获取减重工作台数据统计':
        newRegisteredCustomerNum = str(res.json()['data']['newRegisteredCustomerNum'])
        JZ['newRegisteredCustomerNum'] = newRegisteredCustomerNum
        inServiceCustomerNum = str(res.json()['data']['inServiceCustomerNum'])
        JZ['inServiceCustomerNum'] = inServiceCustomerNum
        endedServiceCustomerNum = str(res.json()['data']['endedServiceCustomerNum'])
        JZ['endedServiceCustomerNum'] = endedServiceCustomerNum
        totalCustomerNum = str(res.json()['data']['totalCustomerNum'])
        JZ['totalCustomerNum'] = totalCustomerNum
        todayClueNum = str(res.json()['data']['todayClueNum'])
        JZ['todayClueNum'] = todayClueNum
        toAllocateClueNum = str(res.json()['data']['toAllocateClueNum'])
        JZ['toAllocateClueNum'] = toAllocateClueNum
        invalidClueNum = str(res.json()['data']['invalidClueNum'])
        JZ['invalidClueNum'] = invalidClueNum
        totalClueNum = str(res.json()['data']['totalClueNum'])
        JZ['totalClueNum'] = totalClueNum
        noNeedNutritionistClueNum = str(res.json()['data']['noNeedNutritionistClueNum'])
        JZ['noNeedNutritionistClueNum'] = noNeedNutritionistClueNum

        extract_txt(config_variable_path, str(JZ))

